<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排他思想</title>
    <style>
    </style>
</head>

<body>
    <div id="root">
        <button>按钮1</button><button>按钮2</button><button>按钮3</button><button>按钮4</button><button>按钮5</button><button>按钮6</button><button>按钮7</button><button>按钮8</button><button>按钮9</button><button>按钮10</button>
    </div>
</body>
<script>
    let bs=document.getElementsByTagName('button')
    for(let i=0;i<bs.length;i++){
        bs[i].onclick=function (){
            console.log(this.innerHTML)
            for(b of bs){
              b.style.backgroundColor=''
            }
            this.style.backgroundColor='pink'
        }
    }
</script>

</html>